function a(arr) {
    const x = [...new Set(arr.map(r => r.data.x))].reduce((p, c) => {
        return p - c
    });
    const y = [...new Set(arr.map(r => r.data.y))].reduce((p, c) => {
        return p - c
    });

    console.log(x, y);
}

a([
    {
        data: {
            x: 0.08,
            y: -3.82,
        },
    },
    {
        data: {
            x: -0.22,
            y: -3.82,
        },
    },
    {
        data: {
            x: -0.22,
            y: -4.42,
        },
    },
    {
        data: {
            x: 0.08,
            y: -4.42,
        },
    },
]);

let n = 5;
const arr = [...new Array(n).keys()]
console.log(arr);
